package ModelLayer;

import java.util.ArrayList;
/**
 * Holds information of Customer objects, designed as a regular class.
 *
 * @author  Danny M.P., Jakob K., Anna K., Anders A.P., Mie P.  
 * @version 1.0
 */
public class Customer extends Person {

    private ArrayList<Order> offers;
    private ArrayList<Order> orders;
    private int              customerNo;
    private static int       counter;

    /**
     * Constructor for objects of class Customer
     *
     * @param name          customer name.
     * @param address       customer address.
     * @param email         customer e-mail.
     * @param tlf           customer phone number.
     */
    public Customer(String name, String address, String email, String tlf) {

        super(name,address,email,tlf);
        offers = new ArrayList<Order>();
        orders = new ArrayList<Order>();
        ++counter;
        this.customerNo = counter;

    }

    /**
     * Returns a list of the customers offers.
     * 
     * @return An ArrayList containing Order objects.
     */
    public ArrayList<Order> getOffers() {

        if (offers.size() > 0) {
            return new ArrayList<Order>(offers);
        }
        else {
            return null;
        }
    }

    /**
     * Returns a list of the customers finished orders.
     * 
     * @return An ArrayList containing Order objects.
     */
    public ArrayList<Order> getOrders() {

        if (orders.size() > 0) {
            return new ArrayList<Order>(orders);
        }
        else {
            return null;
        }

    }

    /**
     * Returns the customer number of a Customer object.
     * 
     * @return customerNo
     */
    public int getCustomerNo() {

        return customerNo;

    }

    /**
     * Adds an Order object to the offers collection.
     * 
     * @param o An Order object.
     */
    public void addOffer(Order o) {

        if (!offers.contains(o)) {
            offers.add(o);
        }

    }

    /**
     * Adds an Order object to the orders collection.
     * 
     * @param o An Order object.
     */
    public void addOrder(Order o) {

        if (!orders.contains(o)) {
            orders.add(o);
        }

    }

    /**
     * Removes an Order object from the offers collection.
     * 
     * @param o An Order object.
     */
    public void removeOffer(Order o) {

        offers.remove(o);

    }
    
}
